package com.arron.DesignMode.prototype.deepclone;

/**
 * @Classname Client
 * @Date 2020/11/6 14:53
 * @Created by 刘
 */
public class Client {


    public static void main(String[] args) throws CloneNotSupportedException {

        DeepPrototype deepPrototype = new DeepPrototype("大牛");

        deepPrototype.setDeepCloneableTarget(new DeepCloneableTarget("小牛"));

        //方式一：使用clone方式
        DeepPrototype deepPrototype1 = deepPrototype.clone();

        System.out.println(deepPrototype.getName()+"?"+deepPrototype1.getName()+"======>"+deepPrototype.getDeepCloneableTarget().hashCode()+"？"+deepPrototype1.getDeepCloneableTarget().hashCode());


        //方式二：使用序列化和反序列化

        DeepPrototype deepPrototype2 = deepPrototype.deepClone();

        System.out.println(deepPrototype.getName()+"?"+deepPrototype2.getName()+"======>"+deepPrototype.getDeepCloneableTarget().hashCode()+"？"+deepPrototype2.getDeepCloneableTarget().hashCode());




    }



}
